home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 010 / wari.bas (.txt) < prev    next >
Encoding:
GW-BASIC  |  1984-04-24  |  7.1 KB  |  171 lines

  1. 10  REM  ********************  WARI.BAS  **************************
  2. 11  KEY OFF:CLS:PRINT "Wari was modified for the IBM PC from the book:
  3. 12  PRINT "`BASIC Programs for the TRS-80'
  4. 15  PRINT "Copyright 1979 by Tom Rugg and Phil Feldman":PRINT
  5. 20  PRINT "Do you wish to read the instructions?"
  6. 21  Y$=INKEY$
  7. 22  IF Y$="" THEN 21
  8. 30  IF Y$="Y" OR Y$="y" THEN GOSUB 3000
  9. 120  DEFINT A-D,J-T,W-Y:J=1:K=1:Q=14:P=13:F=50:D=12
  10. 130  DIM T(14),Y(14),W(14),V(6),E(14),B(14),M(10)
  11. 140  RANDOMIZE INT(VAL(RIGHT$(TIME$,2))):ZB=RND:ZB=ZB/Q:ZA=0.25-ZB:GOSUB 750
  12. 150  FOR J=1 TO D:B(J)=4:NEXT:B(P)=0:B(Q)=0:M(N)=0:GOSUB 1200:GOSUB 900
  13. 160  GOSUB 990:INPUT "WANT TO GO FIRST";R$
  14. 170  GOSUB 990:PRINT D$:R$=LEFT$(R$,1):IF R$="Y" THEN 250
  15. 180  IF R$<>"N" THEN 160
  16. 190  GOSUB 1050:PRINT D$;D$;D$;:GOSUB 1050:PRINT "THINKING";:GOSUB 510
  17. 195  IF M<1 THEN 2000
  18. 200  GOSUB 1050:PRINT D$;:GOSUB 1050:PRINT "MY MOVE IS";M
  19. 210  FOR J=1 TO Q:T(J)=B(J):NEXT:GOSUB 350
  20. 220  FOR J=1 TO Q:B(J)=T(J):NEXT:GOSUB 900
  21. 230  IF B(Q)<24 THEN 250
  22. 240  GOSUB 1050:PRINT "I WIN!";D$:GOTO 810
  23. 250  GOSUB 990:PRINT D$;D$:GOSUB 990:PRINT "YOUR MOVE  ";
  24. 252  R$=INKEY$
  25. 254  IF R$="" GOTO 252
  26. 260  M=INT(VAL(R$)):IF M>6 OR M<1 THEN 330
  27. 265  PRINT R$;
  28. 270  FOR J=1 TO Q:T(J)=B(J):NEXT
  29. 280  GOSUB 350:IF M<0 THEN 330
  30. 290  FOR J=1 TO Q:B(J)=T(J):NEXT
  31. 300  MN=MN+1:GOSUB 900
  32. 310  IF B(P)<24 THEN 190
  33. 320  GOSUB 1050:PRINT "YOU WIN!";D$:GOTO 810
  34. 330  LOCATE 13,20:PRINT " ILLEGAL ";:FOR J=1 TO 3000:NEXT:GOTO 250
  35. 350  IF T(M)=0 THEN M=-1:RETURN
  36. 360  R$="H":IF M>6 THEN R$="C":GOTO 380
  37. 370  FOR J=1 TO Q:Y(J)=T(J):NEXT :GOTO 400
  38. 380  FOR J=1 TO 6:Y(J)=T(J+6):Y(J+6)=T(J):NEXT
  39. 390  Y(P)=T(Q):Y(Q)=T(P):M=M-6
  40. 400  C=M:N=Y(C):FOR J=1 TO N:C=C+1
  41. 410  IF C=P THEN C=1
  42. 420  IF C=M THEN C=C+1:GOTO 410
  43. 430  Y(C)=Y(C)+1:NEXT :Y(M)=0:L=C
  44. 440  IF L<7 OR Y(L)>3 OR Y(L)<2 THEN 460
  45. 450  Y(P)=Y(P)+Y(L):Y(L)=0:L=L-1:GOTO 440
  46. 460  S=0:FOR J =7 TO D:S=S+Y(J):NEXT
  47. 470  IF S=0 THEN M=-2:RETURN
  48. 480  IF R$="H" THEN FOR J=1 TO Q:T(J)=Y(J):NEXT :RETURN
  49. 490  FOR J=1 TO 6:T(J)=Y(J+6):T(J+6)=Y(J):NEXT
  50. 500  T(Q)=Y(P):T(P)=Y(Q):RETURN
  51. 510  FOR A=1 TO 6:M=A+6:IF B(M)=0 THEN E(A)=-F:GOTO 690
  52. 530  FOR J=1 TO Q:T(J)=B(J):NEXT :GOSUB 350
  53. 540  IF M<0 THEN E(A)=-F:GOTO 690
  54. 550  IF T(Q)>23 THEN M=A+6:RETURN
  55. 560  FOR J=1 TO Q:W(J)=T(J):NEXT :FOR K=1 TO 6
  56. 570  IF T(K)=0 THEN V(K)=F:GOTO 670
  57. 580  FOR J=1 TO Q:T(J)=W(J):NEXT :M=K:GOSUB 350
  58. 590  IF M=0 THEN V(K)=F:GOTO 670
  59. 600  FA=0:FB=0:FC=0:FD=0:FOR J=7 TO D
  60. 610  FB=FB+T(J):IF T(J)>0 THEN FA=FA+1
  61. 620  IF T(J)<3 THEN FC=FC+1
  62. 630  IF T(J)>FD THEN FD=T(J)
  63. 640  NEXT :FE=FB:FOR J=1 TO 6:FE=FE+T(J):NEXT
  64. 650  FA=FA/6:FD=1-FD/FB:FC=1-FC/6:FB=FB/FE
  65. 660  V(K)=ZA*(FA+FB)+ZB*(FC+FD)+T(Q)+B(P)-B(Q)-T(P)
  66. 670  NEXT :E(A)=F:FOR J=1 TO 6:IF V(J)<E(A) THEN E(A)=V(J)
  67. 680  NEXT
  68. 690  PRINT ".";:NEXT :M=0:FA=-F:FOR J=1 TO 6
  69. 700  IF E(J)>FA THEN FA=E(J):M=J+6
  70. 710  NEXT :RETURN
  71. 750  A$="KEYTHENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHENCLOSE"
  72. 760  B$="OPEN":FOR J=1 TO 6:B$=B$+"     "+"OPEN":NEXT
  73. 770  C$="TOTHENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENRANDOMIZE"
  74. 780  E$="SCREENTHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOAD"
  75. 790  D$=" ":FOR J=1 TO 5:D$=D$+D$:NEXT :RETURN
  76. 810  PRINT "GOOD GAME!"
  77. 820  INPUT "WANT TO PLAY AGAIN";R$
  78. 850  R$=LEFT$(R$,1):IF R$="Y" THEN 120
  79. 860  IF R$<>"N" THEN 820
  80. 870  PRINT :PRINT "SEE YOU LATTER"
  81. 880  END
  82. 900  FOR J=0 TO 5
  83. 910  LOCATE 6,3+J*6:PRINT B(12-J);
  84. 920  IF B(12-J)=0 THEN GOSUB 1100
  85. 930  NEXT :LOCATE 6,47:PRINT "COMPUTER ";B(Q);
  86. 940  FOR J=0 TO 5
  87. 950  LOCATE 9,3+J*6:PRINT B(J+1);:IF B(J+1)=0 THEN GOSUB 1100
  88. 960  NEXT :LOCATE 9,52:PRINT "YOU ";B(P);:RETURN
  89. 990  LOCATE 13,1:PRINT " ";:RETURN
  90. 1050  LOCATE 14,1:PRINT " ";:RETURN
  91. 1100  PRINT CHR$(29);" ";:RETURN
  92. 1200  CLS:PRINT TAB(30);"W A R I"
  93. 1220  PRINT TAB(14);"COMPUTER"
  94. 1230  FOR J=0 TO 5:PRINT TAB(6*J+2);12-J;:NEXT
  95. 1240  LOCATE 4,1:PRINT A$;TAB(50);"CAPTURED"
  96. 1250  PRINT B$:PRINT B$:PRINT C$
  97. 1252  PRINT B$:PRINT B$:PRINT E$
  98. 1260  FOR J=0 TO 5:PRINT TAB(6*J+2);J+1;:NEXT
  99. 1270  PRINT :PRINT TAB(17);"YOU":RETURN
  100. 2000  PRINT "NO LEGAL MOVES.":GOTO 820
  101. 3000  CLS:LOCATE 1,36:PRINT "W A R I"
  102. 3001  PRINT
  103. 3002  PRINT "PURPOSE"
  104. 3003  PRINT
  105. 3004  PRINT "   Wari is an old game with roots that are even older. Its origins
  106. 3005  PRINT "go back thousands of years to a variety of other similar games,
  107. 3006  PRINT "all classified as being members of the Mancala family. Other
  108. 3007  PRINT "variations are Awari, Oware, Pallanguli, Kalah, and countless
  109. 3008  PRINT "other offshoots.
  110. 3009  PRINT "   The program matches you against the computer. You are
  111. 3010  PRINT "probably going to loose a few games before you win one-the
  112. 3011  PRINT "computer plays a pretty good game. This may hurt your ego a
  113. 3012  PRINT "little bit, since Wari is purely a skill game (like chess or checkers).
  114. 3013  PRINT "There is no element of luck involved, as would be the case with
  115. 3014  PRINT "backgammon, for example. When you loose, it's because you were
  116. 3015  PRINT "outplayed.
  117. 3016  LOCATE 24,1:PRINT "Press any key to continue";
  118. 3017  Y$=INKEY$
  119. 3018  IF Y$="" THEN 3017
  120. 3019  CLS:PRINT "HOW TO USE IT"
  121. 3020  PRINT
  122. 3021  PRINT "  When you start the program, the first thing it does is display the Wari board
  123. 3022  PRINT "and ask you if you want to go first. The board is made up of twelve squares in
  124. 3023  PRINT "in two rows of six. Your side is the bottom side, numbered one through six
  125. 3024  PRINT "from left to right. The computers side is on the top, numbered seven through
  126. 3025  PRINT "twelve from right to left.
  127. 3026  PRINT "  At the start of the game, each square has four `stones' in it. There is no
  128. 3027  PRINT "way to differentiate between your stones and the computer's. They all look
  129. 3028  PRINT "alike and will move from one side to the other during the course of play.
  130. 3029  PRINT "  The first player `picks up' all the stones in one of the squares on his side
  131. 3030  PRINT "of the board and `drops them', one to a square, starting with the next highest
  132. 3031  PRINT "numbered square. The stones continue to be dropped consecutively in each
  133. 3032  PRINT "continuing over onto the opponent's side if necessary (after square 12 comes
  134. 3033  PRINT "square number 1 again).
  135. 3034  PRINT "   If the last stone is dropped onto the opponent's side and leaves a total of
  136. 3035  PRINT "either two or three stones in that square, these stones are captured by the
  137. 3036  PRINT "player who moved, and removed from the board. Also, if the next-to-the last
  138. 3037  PRINT "square in which a stone was dropped meets the same conditions (on the
  139. 3038  PRINT "opponent's side with two or three stones), its stones are also captured. This
  140. 3039  PRINT "continues backwards until the string of consecutive squares of two or three on
  141. 3040  PRINT "the opponent's side is broken.
  142. 3041  LOCATE 24,1:PRINT "Press any key to continue";
  143. 3042  A$=INKEY$
  144. 3043  IF A$="" THEN 3042
  145. 3044  CLS:PRINT "  Regardless of whether any captures are made, play alternates back and forth,
  146. 3045  PRINT "between the two players.
  147. 3046  PRINT "  The object of the game is to be the first player to capture tyenty-four or
  148. 3047  PRINT "more stones. That's half of the forty-eight stones that are on the board at
  149. 3048  PRINT "beginning of the game.
  150. 3049  PRINT "  There are a few special rules to cover some situations that can come up in
  151. 3050  PRINT "game. It is not legal to capture all the stones on the opponent's side of the
  152. 3051  PRINT "board, since this would leave the opponent with no moves on his next turn. By
  153. 3052  PRINT "the same token, when your opponent has no stones on his side (because he had
  154. 3053  PRINT "to move his last one to your side on his turn), you have to make a move that
  155. 3054  PRINT "gives him at least one stone to move on his next turn, if possible. If you
  156. 3055  PRINT "cannot make such a move, the game is over and counted as a draw.
  157. 3056  PRINT "  During the course of the game, it's possible for a square to accumulate
  158. 3057  PRINT "twelve or more stones in it. Moving from such a square causes stones to be
  159. 3058  PRINT "distributed all the way around the board. When this happens, the square from
  160. 3059  PRINT "which the move was made is skipped over. So, the square moved from is always
  161. 3060  PRINT "left empty.
  162. 3061  PRINT "  It takes the computer anywhere from five seconds to about forty seconds to
  163. 3062  PRINT "make a move, depending on the complexity of the board position (Interperter
  164. 3063  PRINT "BASIC only). The word `THINKING' is displayed during this time, and a period
  165. 3064  PRINT "is added to it as each possible move is evaluated in sequence.
  166. 3065  PRINT TAB(37) "- END -"
  167. 3066  LOCATE 24,1:PRINT "Press any key to continue";
  168. 3067  Y$=INKEY$
  169. 3068  IF Y$="" THEN 3066
  170. 3069  RETURN
  171.